﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using COC.Character.AI.Internal.FSM;
using COC.Tools.AI.Motion;

namespace COC.Character.AI.Internal.FSM
{
    public class FSMStack : IFSMStack
    {

        protected internal FSMState CurrState = FSMState.NONE;//get current state when state is attached on character.

        public FSMStack()
        {
//            configureStatesForParse(states);
        }
     
        public override void pushSingleState(AiAction state)
        {
            pushState(state);
        }
        protected void pushState(AiAction state)
        {
           
            {
                enterStack.Push(state);
            }
        }

       
        protected void parseState(AiAction action)
        {
           
          /*  //validate whether state is valid
            int fieldVal=-1;
            foreach (string key in _cacheAllStates)
            {
                 fieldVal=(int)(key);
                 int value = (int)(action.state & fieldVal);
                 if (value == fieldVal)
                {
                    enterStack.Push(action);
                }
            }*/
            /* switch (value)
             {

                 case (int)FMSState.NONE:

                     break;
                 case (int)FMSState.SEEK:

                     break; ;
                 case (int)FMSState.FOLLOW_PATH:

                     break;
                 case (int)FMSState.QUEUE:

                     break;
                 case (int)FMSState.WANDER:

                     break;
                 case (int)FMSState.FLEE:

                     break;
                 case (int)FMSState.COHESION:

                     break;
                 case (int)FMSState.SEPARATION:

                     break;
                 case (int)FMSState.COLLISION_AVOIDANCE:

                     break;
                 case (int)FMSState.ATTACK:

                     break;
                 case (int)FMSState.STANDBY:

                     break;
                 case (int)FMSState.DIED:

                     break;
                 case (int)FMSState.DEFEND:

                     break;
                 default:
                     break;
             }*/
        }
        public override AiAction popState()
        {
          
                if (enterStack.Count != 0)
                {
                    return enterStack.Pop();
                }
              
            
            return null;
        }
        private AiAction peekState()
        {
                return enterStack.Peek();
        }
        public override AiAction getCurrState()
        {
            return peekState();
        }

        public override int cleanStates()
        {
            int count=0;
            {
                count = enterStack.Count;
                enterStack.Clear();
                return count;
            }
        
        }

       
    }
}
